package com.example.kf1703a;

import android.os.Handler;
import android.os.Message;

public class Random_Thread extends  Thread {
    Handler handler;
    String[] students = {"王国桦","田宇","姚鑫河","王泽云","程乾益","王乾硕","刘蔚","苏越","邢艺缤"};
    boolean flag = true;
    public Random_Thread(Handler handler) {
        this.handler = handler;
    }
public void chage(){
        flag = !flag;
}
    @Override
    public void run() {
        while (flag){
            try {
                Thread.sleep(30);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Message message = Message.obtain();
            int index = (int) (Math.random()*students.length);
            message.obj = students[index];
            message.what = 1000;
            handler.sendMessage(message);

        }
    }
}
